package com.jxb.demo.im;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.msgpack.MessagePack;

/**
 * @desc 编码器
 */
public class MsgPackEncoder extends MessageToByteEncoder<MsgInfo> {

    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, MsgInfo msgInfo, ByteBuf byteBuf) throws Exception {
        MessagePack msgPack = new MessagePack();
        byteBuf.writeBytes(msgPack.write(msgInfo));
    }
}
